---------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/wesleyblundell/Dropbox/Wes_Supplemental_NEI/JAERE_Replication/Replication_package/log/Table_1_2_A11_A14Results.log
  log type:  text
 opened on:  15 May 2024, 10:55:19

. use "$rootpath/processed_data/Estimation_Data.dta", clear

. drop if key_estimation_sample!=1
(273,947 observations deleted)

. set seed 99164

. sort frsnumber year, stable

. quietly by frsnumber year:  gen dup = cond(_N==1,0,_n)

. gen duplicated=0

. replace duplicated=1 if dup>1
(10,719 real changes made)

. gsort -duplicated

. gen test_n=_n

. summarize frsnumber

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
   frsnumber |    699,013    1.10e+11    2.14e+07   1.10e+11   1.10e+11

. replace frsnumber=r(max)*10000+test_n if dup>1
(10,719 real changes made)

. drop dup

. sort frsnumber year, stable

. quietly by frsnumber year:  gen dup = cond(_N==1,0,_n)

. drop if dup>1
(0 observations deleted)

. drop dup

. merge 1:1 frsnumber year using "$rootpath/processed_data/estimation_ICIS_plant_file.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                     2,497,367
        from master                   436,906  (_merge==1)
        from using                  2,060,461  (_merge==2)

    matched                           262,107  (_merge==3)
    -----------------------------------------

. drop if _merge==2
(2,060,461 observations deleted)

. drop _merge

. foreach var in quarterly_penaltiesnofed annual_quarterly_tests2 quarterly_full_inspectionsnofed quarterly_part_inspectionsnofed annual_full_inspec annu
> al_part_inspec annual_quarterly_penalties2 annual_tot_hpv2 annual_tot_frv2 {
  2. replace `var'=0 if `var'==.
  3. }
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)

. replace tot_damage=tot_damage/1000000
(685,186 real changes made)

. gen wes_inspec=annual_part_inspec+annual_full_inspec

. gen wes_state_inspec=quarterly_full_inspectionsnofed+quarterly_part_inspectionsnofed

. gen wes_fed_inspec=wes_inspec - wes_state_inspec

. gen wes_fed_penal=annual_quarterly_penalties2 - quarterly_penaltiesnofed

. 
. gen comp_wes=1

. replace comp_wes=0 if (annual_tot_hpv2>0&annual_tot_hpv2!=.)|(annual_tot_frv2>0&annual_tot_frv2!=.)
(18,765 real changes made)

. rename post treatment

. balancetable treatment tot_damage tot_emissions annual_quarterly_penalties2 wes_inspec comp_wes annual_tot_hpv2 annual_tot_frv2 using "$rootpath/table_
> graph/Table_1.tex", pvalues replace 

. 
. ///Table 2 final run 
> drop if annual_tot_hpv2==0&annual_tot_frv2==0
(680,248 observations deleted)

. replace treatment=. if annual_tot_hpv2==0
(8,339 real changes made, 8,339 to missing)

. foreach var in annual_quarterly_penalties2 wes_fed_penal quarterly_penaltiesnofed wes_inspec wes_fed_inspec wes_state_inspec {
  2. gen `var'_orig=`var'
  3. replace `var'=`var'/annual_tot_hpv2
  4. }
(11,804 real changes made, 8,339 to missing)
(9,808 real changes made, 8,339 to missing)
(10,430 real changes made, 8,339 to missing)
(15,266 real changes made, 8,339 to missing)
(11,257 real changes made, 8,339 to missing)
(13,109 real changes made, 8,339 to missing)

. 
. //all plants HPV
. balancetable treatment annual_quarterly_penalties2 wes_fed_penal quarterly_penaltiesnofed wes_inspec wes_fed_inspec wes_state_inspec using "$rootpath/t
> able_graph/COVTable_HPV.tex", pvalues replace 

. drop treatment

. gen treatment=1 if year>2014&annual_tot_hpv2==0
(12,785 missing values generated)

. replace treatment=0 if year<2015&annual_tot_hpv2==0
(2,359 real changes made)

. foreach var in annual_quarterly_penalties2 wes_fed_penal quarterly_penaltiesnofed wes_inspec wes_fed_inspec wes_state_inspec {
  2. 
. replace `var'=`var'_orig/annual_tot_frv2
  3. }
(17,970 real changes made, 8,973 to missing)
(17,486 real changes made, 8,973 to missing)
(17,822 real changes made, 8,973 to missing)
(18,283 real changes made, 8,973 to missing)
(17,608 real changes made, 8,973 to missing)
(18,110 real changes made, 8,973 to missing)

. 
. //all plants FRV
. balancetable treatment annual_quarterly_penalties2 wes_fed_penal quarterly_penaltiesnofed wes_inspec wes_fed_inspec wes_state_inspec using "$rootpath/t
> able_graph/COVTable_FRV.tex", pvalues replace 

. 
. use "$rootpath/processed_data/Estimation_Data.dta", clear

. drop if key_estimation_sample!=1
(273,947 observations deleted)

. set seed 99164

. sort frsnumber year, stable

. quietly by frsnumber year:  gen dup = cond(_N==1,0,_n)

. gen duplicated=0

. replace duplicated=1 if dup>1
(10,719 real changes made)

. gsort -duplicated

. gen test_n=_n

. summarize frsnumber

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
   frsnumber |    699,013    1.10e+11    2.14e+07   1.10e+11   1.10e+11

. replace frsnumber=r(max)*10000+test_n if dup>1
(10,719 real changes made)

. drop dup

. sort frsnumber year, stable

. quietly by frsnumber year:  gen dup = cond(_N==1,0,_n)

. drop if dup>1
(0 observations deleted)

. drop dup

. merge 1:1 frsnumber year using "$rootpath/processed_data/estimation_ICIS_plant_file.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                     2,497,367
        from master                   436,906  (_merge==1)
        from using                  2,060,461  (_merge==2)

    matched                           262,107  (_merge==3)
    -----------------------------------------

. drop if _merge==2
(2,060,461 observations deleted)

. drop _merge

. foreach var in quarterly_penaltiesnofed annual_quarterly_tests2 quarterly_full_inspectionsnofed quarterly_part_inspectionsnofed annual_full_inspec annu
> al_part_inspec annual_quarterly_penalties2 annual_tot_hpv2 annual_tot_frv2 {
  2. replace `var'=0 if `var'==.
  3. }
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)

. replace tot_damage=tot_damage/1000000
(685,186 real changes made)

. gen wes_inspec=annual_part_inspec+annual_full_inspec

. gen wes_state_inspec=quarterly_full_inspectionsnofed+quarterly_part_inspectionsnofed

. gen wes_fed_inspec=wes_inspec - wes_state_inspec

. gen wes_fed_penal=annual_quarterly_penalties2 - quarterly_penaltiesnofed

. 
. gen comp_wes=1

. replace comp_wes=0 if (annual_tot_hpv2>0&annual_tot_hpv2!=.)|(annual_tot_frv2>0&annual_tot_frv2!=.)
(18,765 real changes made)

. rename post treatment

. gen treat=1 if avg_old_code_prob>0.53
(607,128 missing values generated)

. replace treat=0 if avg_old_code_prob<0.23
(116,711 real changes made)

. tab treat

      treat |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    116,711       55.95       55.95
          1 |     91,885       44.05      100.00
------------+-----------------------------------
      Total |    208,596      100.00

. keep if treat==0&treat!=.
(582,302 observations deleted)

. 
. sort frsnumber year

. egen num_obs=nvals(year), by(frsnumber)

. //below is for table a14
. balancetable treatment tot_damage tot_emissions annual_quarterly_penalties2 wes_inspec comp_wes annual_tot_hpv2 annual_tot_frv2 using "$rootpath/table_
> graph/Table_A14_low.tex", pvalues replace 

. drop if annual_tot_hpv2==0&annual_tot_frv2==0
(113,039 observations deleted)

. drop treatment

. gen treatment=1 if year>2014&annual_tot_hpv2>0
(2,911 missing values generated)

. replace treatment=0 if year<2015&annual_tot_hpv2>0
(963 real changes made)

. foreach var in annual_quarterly_penalties2 wes_fed_penal quarterly_penaltiesnofed wes_inspec wes_fed_inspec wes_state_inspec {
  2. gen `var'_orig=`var'
  3. replace `var'=`var'/annual_tot_hpv2
  4. }
(2,420 real changes made, 1,948 to missing)
(2,084 real changes made, 1,948 to missing)
(2,289 real changes made, 1,948 to missing)
(3,045 real changes made, 1,948 to missing)
(2,284 real changes made, 1,948 to missing)
(2,852 real changes made, 1,948 to missing)

. 
. //bottom quintile HPV
. balancetable treatment annual_quarterly_penalties2 wes_fed_penal quarterly_penaltiesnofed wes_inspec wes_fed_inspec wes_state_inspec using "$rootpath/t
> able_graph/COVTable_HPV_low.tex", pvalues replace 

. drop treatment

. gen treatment=1 if year>2014&annual_tot_hpv2==0
(2,279 missing values generated)

. replace treatment=0 if year<2015&annual_tot_hpv2==0
(555 real changes made)

. foreach var in annual_quarterly_penalties2 wes_fed_penal quarterly_penaltiesnofed wes_inspec wes_fed_inspec wes_state_inspec {
  2. replace `var'=`var'_orig/annual_tot_frv2
  3. }
(3,489 real changes made, 1,436 to missing)
(3,404 real changes made, 1,436 to missing)
(3,471 real changes made, 1,436 to missing)
(3,591 real changes made, 1,436 to missing)
(3,432 real changes made, 1,436 to missing)
(3,573 real changes made, 1,436 to missing)

. 
. //bottom quintile FRV
. balancetable treatment annual_quarterly_penalties2 wes_fed_penal quarterly_penaltiesnofed wes_inspec wes_fed_inspec wes_state_inspec using "$rootpath/t
> able_graph/COVTable_FRV_low.tex", pvalues replace 

. 
. 
. use "$rootpath/processed_data/Estimation_Data.dta", clear

. drop if key_estimation_sample!=1
(273,947 observations deleted)

. set seed 99164

. sort frsnumber year, stable

. quietly by frsnumber year:  gen dup = cond(_N==1,0,_n)

. gen duplicated=0

. replace duplicated=1 if dup>1
(10,719 real changes made)

. gsort -duplicated

. gen test_n=_n

. summarize frsnumber

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
   frsnumber |    699,013    1.10e+11    2.14e+07   1.10e+11   1.10e+11

. replace frsnumber=r(max)*10000+test_n if dup>1
(10,719 real changes made)

. drop dup

. sort frsnumber year, stable

. quietly by frsnumber year:  gen dup = cond(_N==1,0,_n)

. drop if dup>1
(0 observations deleted)

. drop dup

. merge 1:1 frsnumber year using "$rootpath/processed_data/estimation_ICIS_plant_file.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                     2,497,367
        from master                   436,906  (_merge==1)
        from using                  2,060,461  (_merge==2)

    matched                           262,107  (_merge==3)
    -----------------------------------------

. drop if _merge==2
(2,060,461 observations deleted)

. drop _merge

. foreach var in quarterly_penaltiesnofed annual_quarterly_tests2 quarterly_full_inspectionsnofed quarterly_part_inspectionsnofed annual_full_inspec annu
> al_part_inspec annual_quarterly_penalties2 annual_tot_hpv2 annual_tot_frv2 {
  2. replace `var'=0 if `var'==.
  3. }
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)
(436,906 real changes made)

. replace tot_damage=tot_damage/1000000
(685,186 real changes made)

. gen wes_inspec=annual_part_inspec+annual_full_inspec

. gen wes_state_inspec=quarterly_full_inspectionsnofed+quarterly_part_inspectionsnofed

. gen wes_fed_inspec=wes_inspec - wes_state_inspec

. gen wes_fed_penal=annual_quarterly_penalties2 - quarterly_penaltiesnofed

. 
. gen comp_wes=1

. replace comp_wes=0 if (annual_tot_hpv2>0&annual_tot_hpv2!=.)|(annual_tot_frv2>0&annual_tot_frv2!=.)
(18,765 real changes made)

. rename post treatment

. gen treat=1 if avg_old_code_prob>0.53
(607,128 missing values generated)

. replace treat=0 if avg_old_code_prob<0.23
(116,711 real changes made)

. tab treat

      treat |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    116,711       55.95       55.95
          1 |     91,885       44.05      100.00
------------+-----------------------------------
      Total |    208,596      100.00

. keep if treat==1&treat!=.
(607,128 observations deleted)

. sort frsnumber year

. egen num_obs=nvals(year), by(frsnumber)

. //below is for table a14
. balancetable treatment tot_damage tot_emissions annual_quarterly_penalties2 wes_inspec comp_wes annual_tot_hpv2 annual_tot_frv2 using "$rootpath/table_
> graph/Table_A14_high.tex", pvalues replace 

. drop if annual_tot_hpv2==0&annual_tot_frv2==0
(87,768 observations deleted)

. drop treatment

. gen treatment=1 if year>2014&annual_tot_hpv2>0
(3,045 missing values generated)

. replace treatment=0 if year<2015&annual_tot_hpv2>0
(1,291 real changes made)

. foreach var in annual_quarterly_penalties2 wes_fed_penal quarterly_penaltiesnofed wes_inspec wes_fed_inspec wes_state_inspec {
  2. gen `var'_orig=`var'
  3. replace `var'=`var'/annual_tot_hpv2
  4. }
(2,685 real changes made, 1,754 to missing)
(1,957 real changes made, 1,754 to missing)
(2,516 real changes made, 1,754 to missing)
(3,433 real changes made, 1,754 to missing)
(2,172 real changes made, 1,754 to missing)
(3,222 real changes made, 1,754 to missing)

. balancetable treatment annual_quarterly_penalties2 wes_fed_penal quarterly_penaltiesnofed wes_inspec wes_fed_inspec wes_state_inspec using "$rootpath/t
> able_graph/COVTable_HPV_high.tex", pvalues replace 

. drop treatment

. gen treatment=1 if year>2014&annual_tot_hpv2==0
(2,736 missing values generated)

. replace treatment=0 if year<2015&annual_tot_hpv2==0
(373 real changes made)

. foreach var in annual_quarterly_penalties2 wes_fed_penal quarterly_penaltiesnofed wes_inspec wes_fed_inspec wes_state_inspec {
  2. replace `var'=`var'_orig/annual_tot_frv2
  3. }
(3,801 real changes made, 1,666 to missing)
(3,511 real changes made, 1,666 to missing)
(3,732 real changes made, 1,666 to missing)
(3,868 real changes made, 1,666 to missing)
(3,561 real changes made, 1,666 to missing)
(3,780 real changes made, 1,666 to missing)

. balancetable treatment annual_quarterly_penalties2 wes_fed_penal quarterly_penaltiesnofed wes_inspec wes_fed_inspec wes_state_inspec using "$rootpath/t
> able_graph/COVTable_FRV_high.tex", pvalues replace 

. 
. log close
      name:  <unnamed>
       log:  /Users/wesleyblundell/Dropbox/Wes_Supplemental_NEI/JAERE_Replication/Replication_package/log/Table_1_2_A11_A14Results.log
  log type:  text
 closed on:  15 May 2024, 10:55:37
---------------------------------------------------------------------------------------------------------------------------------------------------------
